package com.iursp.validate.code.model;

import org.springframework.stereotype.Component;
import org.springframework.web.context.request.ServletWebRequest;

import com.iursp.validate.code.impl.AbstractValidateCodeProcessor;

import javax.imageio.ImageIO;

/**
 * 
 * @ClassName:  ImageCodeProcessor   
 * @Description:发送图片验证码  
 * @author: ruiwu
 * @date:   2018年6月25日 下午7:29:52   
 *
 */
@Component("imageValidateCodeProcessor")
public class ImageCodeProcessor  extends AbstractValidateCodeProcessor<ImageCode>{
    /**
     * 发送图形验证码，将其写到session中
     * @param request
     * @param validateCode
     * @throws Exception
     */
    @Override
    protected void send(ServletWebRequest request, ImageCode validateCode) throws Exception {
        ImageIO.write(validateCode.getImage(), "JPEG", request.getResponse().getOutputStream());
    }
}
